package com.das.mechanic_base.widget;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.das.mechanic_base.R;
import com.das.mechanic_base.base.X3BaseSelfBottomSheetDialog;
import com.das.mechanic_base.utils.X3ScreenUtils;
import com.umeng.analytics.MobclickAgent;

public class X3SelectPhotoDialog extends X3BaseSelfBottomSheetDialog implements View.OnClickListener {

    private TextView tv_selectfrom_report;
    private TextView tv_photoorcarema;
    private TextView tv_cancel;
    private TextView tv_photofromsg;
    private int index;
    public X3SelectPhotoDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected boolean getDialogCancel() {
        return false;
    }

    @Override
    protected int getDialogHeight() {
        return X3ScreenUtils.dipToPx(316,mContext);
    }

    @Override
    protected void initView() {
        tv_selectfrom_report = getView(R.id.tv_selectfrom_report);
        tv_photoorcarema = getView(R.id.tv_photoorcarema);
        tv_photofromsg = getView(R.id.tv_photofromsg);
        tv_cancel = getView(R.id.tv_cancel);
        tv_selectfrom_report.setOnClickListener(this);
        tv_photoorcarema.setOnClickListener(this);
        tv_cancel.setOnClickListener(this);
        tv_photofromsg.setOnClickListener(this);
    }

    public void setCurrentIndex(int index){
        tv_selectfrom_report.setVisibility((index == 2) ? View.VISIBLE : View.GONE);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.x3_dialog_select_photo;
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tv_selectfrom_report) {
            if (ionSelectOnclickListener != null) {
                ionSelectOnclickListener.iOnselectFromReport();
            }
            dismiss();
        } else if (id == R.id.tv_photoorcarema) {
            if (ionSelectOnclickListener != null) {
                ionSelectOnclickListener.iOnselectFromphotoOrCamera();
            }
            dismiss();
        } else if (id == R.id.tv_photofromsg) {
            if (ionSelectOnclickListener != null) {
                ionSelectOnclickListener.iOnselectFromConstruction();
            }
            dismiss();
        } else if (id == R.id.tv_cancel) {
            dismiss();
        }
    }
    IonSelectOnclickListener ionSelectOnclickListener;
    public interface IonSelectOnclickListener{
        void iOnselectFromReport();
        void iOnselectFromphotoOrCamera();
        void iOnselectFromConstruction();
    }
    public void setIonSelectOnclick(IonSelectOnclickListener ionSelectOnclickListener){
        this.ionSelectOnclickListener = ionSelectOnclickListener;
    }
    @Override
    protected void onStart() {
        super.onStart();
        MobclickAgent.onPageStart("施工工艺选择图片弹窗");
    }

    @Override
    protected void onStop() {
        super.onStop();
        MobclickAgent.onPageEnd("施工工艺选择图片弹窗");
    }


}
